home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWToolbx / Sources / FWCursor.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  4.3 KB  |  189 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWCursor.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWCURSOR_H
  13. #include "FWCursor.h"
  14. #endif
  15.  
  16. #ifndef PRCURSOR_H
  17. #include "PRCursor.h"
  18. #endif
  19.  
  20. #ifndef FWSOMENV_H
  21. #include "FWSOMEnv.h"
  22. #endif
  23.  
  24. #ifndef FWEXCLIB_H
  25. #include "FWExcLib.h"
  26. #endif
  27.  
  28. #ifndef FWRESFIL_K
  29. #include "FWResFil.k"
  30. #endif
  31.  
  32. #ifndef FWRESFIL_H
  33. #include "FWResFil.h"
  34. #endif
  35.  
  36. #ifndef FWRESTYP_H
  37. #include "FWResTyp.h"
  38. #endif
  39.  
  40. #ifndef FWSTDDEF_H
  41. #include "FWStdDef.h"
  42. #endif
  43.  
  44. #ifndef FWCFMRES_H
  45. #include "FWCFMRes.h"
  46. #endif
  47.  
  48. #if defined(FW_BUILD_MAC) && !defined(__RESOURCES__)
  49. #include <Resources.h>
  50. #endif
  51.  
  52. #if defined(FW_BUILD_MAC) && !defined(__TOOLUTILS__)
  53. #include <ToolUtils.h>
  54. #endif
  55.  
  56. #if defined(FW_BUILD_MAC) && !defined(__LOWMEM__)
  57. #include <LowMem.h>
  58. #endif
  59.  
  60. //========================================================================================
  61. //    Runtime Informations
  62. //========================================================================================
  63.  
  64. #ifdef FW_BUILD_MAC    
  65. #pragma segment fwtoolbx
  66. #endif
  67.  
  68. //========================================================================================
  69. // CLASS FW_CCursor
  70. //========================================================================================
  71.  
  72. FW_DEFINE_AUTO(FW_CCursor)
  73.  
  74. //----------------------------------------------------------------------------------------
  75. //  FW_CCursor::FW_CCursor 
  76. //----------------------------------------------------------------------------------------
  77. //  Create an arrow cursor
  78.  
  79. FW_CCursor::FW_CCursor() :
  80.     fInstance(FW_gInstance),
  81.     fCursorID(FW_kArrowCursor),
  82.     fCursorHandle(NULL),
  83.     fMacIsColor(FALSE)
  84. {
  85.     FW_END_CONSTRUCTOR
  86. }
  87.  
  88. //----------------------------------------------------------------------------------------
  89. //  FW_CCursor::FW_CCursor 
  90. //----------------------------------------------------------------------------------------
  91.  
  92. FW_CCursor::FW_CCursor(FW_CursorID cursorID, FW_Instance instance) :
  93.     fInstance(instance),
  94.     fCursorID(cursorID),
  95.     fCursorHandle(NULL),
  96.     fMacIsColor(FALSE)
  97. {
  98.     FW_END_CONSTRUCTOR
  99. }
  100.  
  101. //----------------------------------------------------------------------------------------
  102. //    FW_CCursor::~FW_CCursor
  103. //----------------------------------------------------------------------------------------
  104.  
  105. FW_CCursor::~FW_CCursor()
  106. {
  107.     FW_START_DESTRUCTOR
  108.     
  109.     if (fCursorHandle != NULL)
  110.     {
  111. #ifdef FW_BUILD_MAC
  112.     if(fMacIsColor)
  113.         ::DisposeCCursor((CCrsrHandle)fCursorHandle);
  114.     else
  115.         ::DisposeHandle((FW_PlatformHandle)fCursorHandle);
  116. #endif
  117. #ifdef FW_BUILD_WIN
  118.     ::DestroyCursor(fCursorHandle);
  119. #endif
  120.     }
  121.     
  122.     fCursorHandle = NULL;
  123. }
  124.  
  125. //----------------------------------------------------------------------------------------
  126. // FW_CCursor::Select
  127. //----------------------------------------------------------------------------------------
  128.  
  129. void FW_CCursor::Select() const
  130. {
  131.     FW_CCursor* self = (FW_CCursor*)this;
  132.     
  133.     self->PrivLoadCursor();
  134.     
  135. #ifdef FW_BUILD_MAC    
  136.     if (fCursorHandle != NULL)
  137.     {
  138.         if(fMacIsColor)
  139.             ::SetCCursor((CCrsrHandle)fCursorHandle);
  140.         else
  141.             ::SetCursor(*fCursorHandle);
  142.     }
  143.     else
  144.         ::SetCursor(&FW_QDGlobals.arrow);
  145.     
  146. #endif
  147.  
  148. #ifdef FW_BUILD_WIN
  149.     FW_ASSERT(fCursorHandle != NULL);
  150.     ::SetCursor(fCursorHandle);
  151. #endif
  152. }
  153.  
  154. //----------------------------------------------------------------------------------------
  155. //    FW_CCursor::PrivLoadCursor
  156. //----------------------------------------------------------------------------------------
  157.  
  158. void FW_CCursor::PrivLoadCursor()
  159. {
  160.     if (fCursorHandle != NULL)
  161.         return;
  162.  
  163. #ifdef FW_BUILD_MAC
  164.     if (fCursorID == FW_kArrowCursor)
  165.         return;
  166. #endif
  167.     
  168.     FW_SOMEnvironment ev;
  169.     fCursorHandle = FW_PrivLoadCursor(ev, fInstance, fCursorID, fMacIsColor);
  170. }
  171.  
  172. //----------------------------------------------------------------------------------------
  173. //    FW_CCursor::GetHandle
  174. //----------------------------------------------------------------------------------------
  175. // On the Mac returns NULL for the arrow cursor
  176.  
  177. FW_PlatformCursorHandle FW_CCursor::GetHandle() const
  178. {
  179.     FW_CCursor* self = (FW_CCursor*)this;
  180.     self->PrivLoadCursor();
  181.  
  182. #ifdef FW_BUILD_WIN
  183.     FW_ASSERT(fCursorHandle);
  184. #endif
  185.     
  186.     return fCursorHandle;
  187. }
  188.  
  189.